package demo2;

//使用关键字interface来定义接口
interface IShape {

    //接口中的成员默认是“public static final”的
    //String name3 = "1";


    //void前边什么也不写，默认为“public abstract”
    void draw();

    public static void staticFunc(){
        System.out.println("这是static修饰的方法！！！");
    }

}

class Rect implements IShape {

    @Override
    public void draw() {
        System.out.println("矩形！");
    }

}
class Flower implements IShape {
    @Override
    public void draw() {
        System.out.println("❀！");
    }
}

public class Text3 {
    public static void drawMap(IShape shape) {
        shape.draw();
    }
    public static void main(String[] args) {

        //接口不能被实例化
        //IShape shape = new IShape();

        IShape shape = new Rect();//向上转型
        IShape shape2 = new Flower();//向上转型
        drawMap(shape);
        drawMap(shape2);

        //接口中可以有static修饰的方法
        IShape.staticFunc();
    }
}
